<?php

class Feedback_result_con extends CI_Controller {

    function __construct() {
        parent::__construct();
    }

    function index() {
        $this->login();
    }

    function login() {
        if ($this->session->userdata('login') == TRUE) {
            redirect(base_url() . 'feedback_result/feedback_result_con/start_home');
        }
        $kosong['list_term'] = array();
        $this->load->view('feedback_result/feedback_result_header_view');
        $this->load->view('feedback_result/form_login');
        $this->load->view('feedback_result/feedback_result_footer_view');
    }

    function proses_login() {
        //mencegah ada yang langsung ke url proses_login, jenis error 0
        if (!isset($_POST['username']) || !isset($_POST['password'])) {
            redirect(base_url() . 'feedback_result/feedback_result_con/error_display');
        }

        $usr = $this->input->post('username');
        $pwd = md5($this->input->post('password'));

        $query_peserta = $this->db->query('select * from user natural join pengajar where user.USERNAME="' . $usr . '" and user.PASSWORD="' . $pwd . '" and pengajar.ID=user.ID');
        if (count($query_peserta->result_array()) != 1) {
            //error jika ada kesalahan login, jenis error 1
            redirect(base_url() . 'feedback_result/feedback_result_con/error_display/1');
        } else {

            $query_term = $this->db->query('select * from term where STATUS="SEDANG"');
            $tgl_now = date('Y-m-d', time());
            $data_peserta = $query_peserta->row_array();
            $data_term = $query_term->row_array();

            if (empty($data_peserta['FOTO'])) {
                $data_peserta['FOTO'] = base_url() . 'foto/default.jpg';
            }

            $data_session = array(
                'id' => $data_peserta['ID'],
                'nama' => $data_peserta['NAMA'],
                'foto' => $data_peserta['FOTO'],
                'no_term' => $data_term['NO_TERM'],
                'tahun_term' => $data_term['TAHUN'],
                'login' => true,
            );
            $this->session->set_userdata($data_session);

            redirect(base_url() . 'feedback_result/feedback_result_con/start_home');
        }
    }


    function start_home($sort=1) {
        if ($this->session->userdata('login') != TRUE) {
            redirect(base_url() . 'feedback_result/feedback_result_con/error_display');
        }
        $id = $this->session->userdata('id');
//        if ($term_sf==0){
        $term_sf = $this->session->userdata('no_term');
        $tahun_sf = $this->session->userdata('tahun_term');
//        }
        $jum = $this->db->query('select KODE_PELATIHAN, ANGKATAN, NAMA_PELATIHAN, JAM_TOTAL, JAM_PER_SESI  from kelas natural join pelatihan where kelas.STATUS<>"BELUM" and kelas.TERM=' . $term_sf . ' and kelas.TAHUN=' . $tahun_sf . '');
        $hasil = $jum->result_array();
        $jum_course = count($hasil);
        $display['jumlah_course'] = $jum_course;

        $overal_course = array();
        for ($data = 0; $data < $jum_course; $data++) {
            $total = $hasil[$data]['JAM_TOTAL'];
            $persesi = $hasil[$data]['JAM_PER_SESI'];

            $getOveral = $this->calculate_overal($total / $persesi, $hasil, $data);

            $nilai_overal_course = 0;
            $count_overal_course = 0;
            for ($q = 1; $q <= ($total / $persesi); $q++) {
                if ($getOveral['jumlah_overal'][$q] != 0) {
                    $jumlah_hadir = $this->db->query('SELECT COUNT(ID) as jumlah FROM `absen` WHERE ANGKATAN="' . $hasil[$data]['ANGKATAN'] . '" and KODE_PELATIHAN="' . $hasil[$data]['KODE_PELATIHAN'] . '" and NOMOR_SESI=' . $q . '')->row()->jumlah;
                    $temp_overal_all = $getOveral['overal_sesi'][$q];
                    $nilai_overal_course = $nilai_overal_course + (((95 / 100) * $temp_overal_all) + ((5 / 100) * (($jumlah_hadir / 17) * $temp_overal_all)));
                    $count_overal_course+=1;
                }
            }
            if ($count_overal_course != 0) {
                $nilai_overal_course = $nilai_overal_course / $count_overal_course;
            } else {
                $nilai_overal_course = 0;
            }
            $nilai_overal_course = $this->decimal($nilai_overal_course);
            $overal_course[$data] = $nilai_overal_course;
            $overal_urut[$data]['KODE_PELATIHAN'] = $hasil[$data]['KODE_PELATIHAN'];
            $overal_urut[$data]['ANGKATAN'] = $hasil[$data]['ANGKATAN'];
            $overal_urut[$data]['NILAI'] = $nilai_overal_course;
            $instruktur_urut[$data]['NILAI'] = $getOveral['nilai_instruktur'];
            $instruktur_urut[$data]['NAMA'] = $getOveral['nama_instruktur'];
            $instruktur_urut[$data]['KODE_PELATIHAN'] = $hasil[$data]['KODE_PELATIHAN'];
            $instruktur_urut[$data]['ANGKATAN'] = $hasil[$data]['ANGKATAN'];
        }
        
        $hasil_urut = $hasil;
        if($sort==1){
            for ($x = 0; $x < count($overal_course); $x++) {
                for ($y = 0; $y < count($overal_course); $y++) {
                    if ($hasil_urut[$x]['KODE_PELATIHAN']<$hasil_urut[$y]['KODE_PELATIHAN'] ) {
                        $hold = $overal_course[$x];
                        $overal_course[$x] = $overal_course[$y];
                        $overal_course[$y] = $hold;
                        
                        $hold2 = $hasil_urut[$x];
                        $hasil_urut[$x] = $hasil_urut[$y];
                        $hasil_urut[$y] = $hold2;
                    }
                }
            }
        } else if($sort==2){
            for ($x = 0; $x < count($overal_course); $x++) {
                for ($y = 0; $y < count($overal_course); $y++) {
                    if ($overal_course[$x] > $overal_course[$y]) {
                        $hold = $overal_course[$x];
                        $overal_course[$x] = $overal_course[$y];
                        $overal_course[$y] = $hold;
                        $hold2 = $hasil_urut[$x];
                        $hasil_urut[$x] = $hasil_urut[$y];
                        $hasil_urut[$y] = $hold2;
                    }
                }
            }
        }

        
        $display['course'] = $hasil_urut;
        $display['overal_course'] = $overal_course;

        for ($x = 0; $x < $jum_course; $x++) {
            for ($y = 0; $y < $jum_course; $y++) {
                if ($overal_urut[$x]['NILAI'] > $overal_urut[$y]['NILAI']) {
                    $hold = $overal_urut[$x];
                    $overal_urut[$x] = $overal_urut[$y];
                    $overal_urut[$y] = $hold;
                }
            }
        }
//        echo "urutan overal";
//        for($x = 0; $x < $jum_course; $x++)
//            echo $overal_urut[$x]['KODE_PELATIHAN'] ." ".$overal_urut[$x]['ANGKATAN']." ".$overal_urut[$x]['NILAI']. "<br>";
        if ($jum_course == 0) {
            $overal_urut = 0;
        }
        $display['overal_urut'] = $overal_urut;

//        echo "urutan instruktur";
//       for ($r=0;$r<count($jum_course);$r++) {
//            echo "<br>".$instruktur_urut[$r]['NAMA']." ".$instruktur_urut[$r]['KODE_PELATIHAN']." ".$instruktur_urut[$r]['ANGKATAN']. " ".$instruktur_urut[$r]['NILAI'];
//        }

        $list_kode_instruktur_dummy = $this->db->query('SELECT distinct ajar.ID as ID, user.NAMA as NAMA, user.FOTO as FOTO, ajar.KODE_PELATIHAN as KODE_PELATIHAN, ajar.ANGKATAN as ANGKATAN FROM ajar inner join user on ajar.ID=user.ID where PERAN ="instruktur"')->result_array();
        $ada = 0;
        $list_kode_instruktur = Array();
        for ($m = 0; $m < count($list_kode_instruktur_dummy); $m++) {
            $filter = $this->db->query('SELECT * from kelas where KODE_PELATIHAN="' . $list_kode_instruktur_dummy[$m]['KODE_PELATIHAN'] . '" 
                and ANGKATAN=' . $list_kode_instruktur_dummy[$m]['ANGKATAN'] . ' and TERM=' . $term_sf . ' and TAHUN=' . $tahun_sf . '')->result_array();
            if (count($filter) > 0) {
                $list_kode_instruktur[$ada] = $list_kode_instruktur_dummy[$m];
                $ada+=1;
                //echo count($filter).'='.$filter[0]['KODE_PELATIHAN'].$filter[0]['ANGKATAN'].'<br>';
                //echo $list_kode_instruktur[$ada-1]['KODE_PELATIHAN'];
            }
        }
        for ($r = 0; $r < count($list_kode_instruktur); $r++) {
//            echo "<br>".$list_kode_instruktur[$r]['ID']." ".$list_kode_instruktur[$r]['NAMA']." ".$list_kode_instruktur[$r]['KODE_PELATIHAN']." a:".$list_kode_instruktur[$r]['ANGKATAN'];
            $sum_instruktur = 0;
            $session_room_instruktur = $this->db->query('SELECT NOMOR_SESI FROM ajar where KODE_PELATIHAN="' . $list_kode_instruktur[$r]['KODE_PELATIHAN'] . '" and ANGKATAN=' . $list_kode_instruktur[$r]['ANGKATAN'] . ' and PERAN="instruktur" and ID=' . $list_kode_instruktur[$r]['ID'] . ';')->result_array();
            if (count($session_room_instruktur) == 0) {
                $session_room_instruktur = 0;
            }
            $instruktur_terurut[$r]['NGAJAR'] = count($session_room_instruktur);
            if(count($session_room_instruktur)>1){
                $sum_course_instruktur = 0;
                for ($s = 0; $s < count($session_room_instruktur); $s++) {
    //                echo "<br>".$list_kode_asisten[$r]['KODE_PELATIHAN']." ".$list_kode_asisten[$r]['ANGKATAN']." ".$session_room[$s]['NOMOR_SESI'];
                    $nilai_room_instruktur = $this->db->query('SELECT NILAI FROM nilai_pengajar where KODE_PELATIHAN="' . $list_kode_instruktur[$r]['KODE_PELATIHAN'] . '" and ANGKATAN=' . $list_kode_instruktur[$r]['ANGKATAN'] . ' and ID_DINILAI=' . $list_kode_instruktur[$r]['ID'] . ' and NOMOR_SESI=' . $session_room_instruktur[$s]['NOMOR_SESI'] . ';')->result_array();
                    $sum_sesi_instruktur = 0;
                    for ($t = 0; $t < count($nilai_room_instruktur); $t++) {
    //                    echo "<br>".$list_kode_asisten[$r]['KODE_PELATIHAN']." ".$list_kode_asisten[$r]['ANGKATAN']." ".$session_room[$s]['NOMOR_SESI']." ".$nilai_room[$t]['NILAI'];
                        $sum_sesi_instruktur+=$nilai_room_instruktur[$t]['NILAI'];
                    }
                    if (count($nilai_room_instruktur) == 0) {
                        $nilai_room_instruktur = 0;
                    }
    //                echo "<br>avg sesi".$session_room[$s]['NOMOR_SESI']."=".$sum_sesi/count($nilai_room);
                    $sum_course_instruktur += $sum_sesi_instruktur / count($nilai_room_instruktur);
                }
    //            echo "<br>avg course".$list_kode_instruktur[$r]['KODE_PELATIHAN']."-".$list_kode_instruktur[$r]['ANGKATAN']."=".$sum_course_instruktur/count($session_room_instruktur);
                $instruktur_terurut[$r]['NAMA'] = $list_kode_instruktur[$r]['NAMA'];
                $instruktur_terurut[$r]['FOTO'] = $list_kode_instruktur[$r]['FOTO'];
                $instruktur_terurut[$r]['KODE_PELATIHAN'] = $list_kode_instruktur[$r]['KODE_PELATIHAN'];
                $instruktur_terurut[$r]['ANGKATAN'] = $list_kode_instruktur[$r]['ANGKATAN'];
                $instruktur_terurut[$r]['NILAI'] = $this->decimal($sum_course_instruktur / count($session_room_instruktur));
            }
//            echo "<br>".$list_kode_asisten[$r]['KODE_PELATIHAN']." ".$list_kode_asisten[$r]['ANGKATAN']." ".$list_kode_asisten[$r]['ID']." ".$asisten_terurut[$r]['NAMA']." ".$asisten_terurut[$r]['NILAI'];
//            echo "<br>avg".$sum_instruktur."/".count($instruktur_room)."=".$instruktur_terurut[$r]['NILAI'];
//            echo "<br>".$list_kode_instruktur[$r]['KODE_PELATIHAN']." ".$list_kode_instruktur[$r]['ANGKATAN']." ".$list_kode_instruktur[$r]['ID']." ".$instruktur_terurut[$r]['NAMA']." ".$instruktur_terurut[$r]['NILAI'];
//            echo "<br>avg".$sum_instruktur."/".count($instruktur_room)."=".$instruktur_terurut[$r]['NILAI'];
        }
        $list_kode_instruktur_baru = $instruktur_terurut;
        $instruktur_terurut = array();
        for ($x = 0; $x < count($list_kode_instruktur_baru); $x++) {
            if($list_kode_instruktur_baru[$x]['NGAJAR']>1){
                $instruktur_terurut[]=$list_kode_instruktur_baru[$x];
            }
        }
        for ($x = 0; $x < count($instruktur_terurut); $x++) {
            for ($y = 0; $y < count($instruktur_terurut); $y++) {
                if ($instruktur_terurut[$x]['NILAI'] > $instruktur_terurut[$y]['NILAI']) {
                    $hold = $instruktur_terurut[$x];
                    $instruktur_terurut[$x] = $instruktur_terurut[$y];
                    $instruktur_terurut[$y] = $hold;
                }
            }
        }
        //for ($r = 0; $r < count($instruktur_terurut); $r++) {
        //    echo "<br>".$instruktur_terurut[$r]['NAMA']." ".$instruktur_terurut[$r]['KODE_PELATIHAN']." ".$instruktur_terurut[$r]['ANGKATAN']." ".$instruktur_terurut[$r]['NILAI'];
        //}

//        echo "<br><br>asisten";
//        $list_kode_asisten = $this->db->query('SELECT distinct nilai_pengajar.ID_DINILAI as ID, nilai_pengajar.KODE_PELATIHAN as KODE_PELATIHAN,  nilai_pengajar.ANGKATAN as ANGKATAN FROM nilai_pengajar inner join ajar on ajar.ID = nilai_pengajar.ID_DINILAI where ajar.PERAN ="asisten"')->result_array();
//        for ($r=0;$r<count($list_kode_asisten);$r++) {
//            echo "<br>".$list_kode_asisten[$r]['ID']." ".$list_kode_asisten[$r]['KODE_PELATIHAN']." a:".$list_kode_asisten[$r]['ANGKATAN'];
//            $sum_asisten = 0;
//            $asisten_room = $this->db->query('SELECT distinct user.ID as id, user.NAMA as nama,user.FOTO as foto, nilai_pengajar.NOMOR_SESI as NOMOR_SESI, nilai_pengajar.NILAI as nilai FROM (nilai_pengajar inner join user on user.ID=nilai_pengajar.ID_DINILAI) inner join ajar on ajar.ID=nilai_pengajar.ID_DINILAI where nilai_pengajar.KODE_PELATIHAN="'.$list_kode_asisten[$r]['KODE_PELATIHAN'].'" and nilai_pengajar.ANGKATAN='.$list_kode_asisten[$r]['ANGKATAN'].' and ajar.PERAN="asisten" and user.ID='.$list_kode_asisten[$r]['ID'].';')->result_array();
//
//            for ($s=0;$s<count($asisten_room);$s++) {
//                echo "<br>".$list_kode_asisten[$r]['KODE_PELATIHAN']." ".$list_kode_asisten[$r]['ANGKATAN']." ".$asisten_room[$s]['id']." ".$asisten_room[$s]['nama']." ".$asisten_room[$s]['NOMOR_SESI']." ".$asisten_room[$s]['nilai'];
//                $sum_asisten+=$asisten_room[$s]['nilai'];
//            }
//            $asisten_terurut[$r]['NAMA'] = $asisten_room[0]['nama'];
//            $asisten_terurut[$r]['FOTO'] = $asisten_room[0]['foto'];
//            $asisten_terurut[$r]['KODE_PELATIHAN'] = $list_kode_asisten[$r]['KODE_PELATIHAN'];
//            $asisten_terurut[$r]['ANGKATAN'] = $list_kode_asisten[$r]['ANGKATAN'];
//            $asisten_terurut[$r]['NILAI'] = $this->decimal($sum_asisten/count($asisten_room));
////            echo "<br>".$list_kode_asisten[$r]['KODE_PELATIHAN']." ".$list_kode_asisten[$r]['ANGKATAN']." ".$list_kode_asisten[$r]['ID']." ".$asisten_terurut[$r]['NAMA']." ".$asisten_terurut[$r]['NILAI'];
////            echo "<br>avg".$sum_instruktur."/".count($instruktur_room)."=".$instruktur_terurut[$r]['NILAI'];
//        }
        $list_kode_asisten_dummy = $this->db->query('SELECT distinct ajar.ID as ID, user.NAMA as NAMA, user.FOTO as FOTO, ajar.KODE_PELATIHAN as KODE_PELATIHAN, ajar.ANGKATAN as ANGKATAN FROM ajar inner join user on ajar.ID=user.ID where PERAN ="asisten"')->result_array();
        $ada = 0;
        $list_kode_asisten = Array();
        for ($m = 0; $m < count($list_kode_asisten_dummy); $m++) {
            $filter = $this->db->query('SELECT * from kelas where KODE_PELATIHAN="' . $list_kode_asisten_dummy[$m]['KODE_PELATIHAN'] . '" 
                and ANGKATAN=' . $list_kode_asisten_dummy[$m]['ANGKATAN'] . ' and TERM=' . $term_sf . ' and TAHUN=' . $tahun_sf . '')->result_array();
            if (count($filter) > 0) {
                $list_kode_asisten[$ada] = $list_kode_asisten_dummy[$m];
                $ada+=1;
                //echo count($filter).'='.$filter[0]['KODE_PELATIHAN'].$filter[0]['ANGKATAN'].'<br>';
                //echo $list_kode_instruktur[$ada-1]['KODE_PELATIHAN'];
            }
        }
        for ($r = 0; $r < count($list_kode_asisten); $r++) {
//            echo "<br>".$list_kode_asisten[$r]['ID']." ".$list_kode_asisten[$r]['NAMA']." ".$list_kode_asisten[$r]['KODE_PELATIHAN']." a:".$list_kode_asisten[$r]['ANGKATAN'];
            $sum_asisten = 0;
            $session_room = $this->db->query('SELECT NOMOR_SESI FROM ajar where KODE_PELATIHAN="' . $list_kode_asisten[$r]['KODE_PELATIHAN'] . '" and ANGKATAN=' . $list_kode_asisten[$r]['ANGKATAN'] . ' and PERAN="asisten" and ID=' . $list_kode_asisten[$r]['ID'] . ';')->result_array();
            if (count($session_room) == 0) {
                $session_room = 0;
            }
            $asisten_terurut[$r]['NGAJAR'] = count($session_room);
            if(count($session_room)>1){
                $sum_course = 0;
                for ($s = 0; $s < count($session_room); $s++) {
    //                echo "<br>".$list_kode_asisten[$r]['KODE_PELATIHAN']." ".$list_kode_asisten[$r]['ANGKATAN']." ".$session_room[$s]['NOMOR_SESI'];
                    $nilai_room = $this->db->query('SELECT NILAI FROM nilai_pengajar where KODE_PELATIHAN="' . $list_kode_asisten[$r]['KODE_PELATIHAN'] . '" and ANGKATAN=' . $list_kode_asisten[$r]['ANGKATAN'] . ' and ID_DINILAI=' . $list_kode_asisten[$r]['ID'] . ' and NOMOR_SESI=' . $session_room[$s]['NOMOR_SESI'] . ';')->result_array();
                    $sum_sesi = 0;
                    //echo count($nilai_room).'<br>';
                    for ($t = 0; $t < count($nilai_room); $t++) {
    //                    echo "<br>".$list_kode_asisten[$r]['KODE_PELATIHAN']." ".$list_kode_asisten[$r]['ANGKATAN']." ".$session_room[$s]['NOMOR_SESI']." ".$nilai_room[$t]['NILAI'];
                        $sum_sesi+=$nilai_room[$t]['NILAI'];
                    }
                    if (count($nilai_room) == 0) {
                        $nilai_room = 0;
                    }
                    //echo "<br>avg sesi".$session_room[$s]['NOMOR_SESI']."=".$sum_sesi/count($nilai_room);
                    $sum_course += $sum_sesi / count($nilai_room);
                }
    //            echo "<br>avg course".$list_kode_asisten[$r]['KODE_PELATIHAN']."-".$list_kode_asisten[$r]['ANGKATAN']."=".$sum_course/count($session_room);
                $asisten_terurut[$r]['NAMA'] = $list_kode_asisten[$r]['NAMA'];
                $asisten_terurut[$r]['FOTO'] = $list_kode_asisten[$r]['FOTO'];
                $asisten_terurut[$r]['KODE_PELATIHAN'] = $list_kode_asisten[$r]['KODE_PELATIHAN'];
                $asisten_terurut[$r]['ANGKATAN'] = $list_kode_asisten[$r]['ANGKATAN'];
                $asisten_terurut[$r]['NILAI'] = $this->decimal($sum_course / count($session_room));
            }
//            echo "<br>".$list_kode_asisten[$r]['KODE_PELATIHAN']." ".$list_kode_asisten[$r]['ANGKATAN']." ".$list_kode_asisten[$r]['ID']." ".$asisten_terurut[$r]['NAMA']." ".$asisten_terurut[$r]['NILAI'];
//            echo "<br>avg".$sum_instruktur."/".count($instruktur_room)."=".$instruktur_terurut[$r]['NILAI'];
        }
        $list_kode_asisten_baru = $asisten_terurut;
        $asisten_terurut = array();
        for ($x = 0; $x < count($list_kode_asisten_baru); $x++) {
            if($list_kode_asisten_baru[$x]['NGAJAR']>1)
                $asisten_terurut[]=$list_kode_asisten_baru[$x];
        }
        
        for ($x = 0; $x < count($asisten_terurut); $x++) {
            for ($y = 0; $y < count($asisten_terurut); $y++) {
                if ($asisten_terurut[$x]['NILAI'] > $asisten_terurut[$y]['NILAI']) {
                    $hold = $asisten_terurut[$x];
                    $asisten_terurut[$x] = $asisten_terurut[$y];
                    $asisten_terurut[$y] = $hold;
                }
            }
        }
        //for ($r = 0; $r < count($asisten_terurut); $r++) {
        //    echo "<br>".$asisten_terurut[$r]['NAMA']." ".$asisten_terurut[$r]['KODE_PELATIHAN']." ".$asisten_terurut[$r]['ANGKATAN']." ".$asisten_terurut[$r]['NILAI'];
        //}

        // last comment
        $comment = $this->db->query('select b.NAMA as NAMA, b.FOTO as FOTO, a.KODE_PELATIHAN AS KODE_PELATIHAN, a.ANGKATAN AS ANGKATAN,
            a.NOMOR_SESI AS NOMOR_SESI, a.KOMENTAR AS KOMENTAR from komentar_pengajar as a inner join user as b on a.ID=b.ID')->result_array();
        $mulai = 0;
        if(count($comment)>6){
            $mulai = count($comment)-6;
        }
        $last_comment = array();
        $counter=0;
        for($i=$mulai;$i<count($comment);$i++){
            $last_comment[$counter] = $comment[$i];
            $counter+=1;
        }
        $display['comment'] = $last_comment;
        
        if (!empty($instruktur_terurut))
            $display['instruktur_urut'] = $instruktur_terurut;
        if (!empty($asisten_terurut))
            $display['asisten_urut'] = $asisten_terurut;
        $display['no_term'] = $term_sf;
        $display['tahun_term'] = $tahun_sf;

        $query_term = $this->db->query('select * from term')->result_array();
        $list_term = array();
        $cur_term = 0;
        if (count($query_term) != 0) {
            for ($p = 0; $p < count($query_term); $p++) {
                $list_term[$query_term[$p]['NO_TERM'] . '/' . $query_term[$p]['TAHUN']] = "Term " . $query_term[$p]['NO_TERM'] . " - " . $query_term[$p]['TAHUN'];
            }
        } else {
            $list_term = $query_term;
        }
        $header_term['list_term'] = $list_term;
        $header_term['cur_term'] = $term_sf . "/" . $tahun_sf;

//        $attr = 'onChange="document.location.href=\''.base_url().'feedback_result/feedback_result_con/start_home/'.$term_sf.'/'.$tahun_sf.'\';"';
        $attr = 'id="list_term" onChange="call(\'' . base_url() . 'feedback_result/feedback_result_con/\')"';
        $header_term['atribut'] = $attr;
        $display['cur_term'] = $term_sf . "/" . $tahun_sf;
        $this->load->view('feedback_result/feedback_result_header_view', $header_term);
        $this->load->view('feedback_result/home_hasil', $display);
        $this->load->view('feedback_result/feedback_result_footer_view');
    }

    function calculate_course($kode, $angk, $sesi = 1) {
        if ($this->session->userdata('login') != TRUE) {
            redirect(base_url() . 'feedback_result/feedback_result_con/error_display');
        }
//        if ($term_sf==0){
        $term_sf = $this->session->userdata('no_term');
        $tahun_sf = $this->session->userdata('tahun_term');
//        }
        $id = $this->session->userdata('id');
        $jum = $this->db->query('select KODE_PELATIHAN, ANGKATAN, NAMA_PELATIHAN, JAM_TOTAL, JAM_PER_SESI from kelas natural join pelatihan where kelas.status="JALAN" and kelas.KODE_PELATIHAN="' . $kode . '" and kelas.ANGKATAN=' . $angk);
        $hasil = $jum->result_array();
        if (count($hasil) == 0) {
            redirect(base_url() . 'feedback_result/feedback_result_con/error_display/4');
        }
        $jum_course = count($hasil);
        $display['jumlah_course'] = $jum_course;
        $display['course'] = $hasil[0];
        $total = $hasil[0]['JAM_TOTAL'];
        $persesi = $hasil[0]['JAM_PER_SESI'];

        $jumlah_hadir = $this->db->query('SELECT COUNT(ID) as jumlah FROM `absen` WHERE ANGKATAN="' . $hasil[0]['ANGKATAN'] . '" and KODE_PELATIHAN="' . $hasil[0]['KODE_PELATIHAN'] . '" and NOMOR_SESI=' . $sesi . '')->row()->jumlah;
        $jumlah_peserta_kelas = $this->db->query('SELECT COUNT(ID_USER) as jum_pk FROM `peserta_kelas` WHERE ANGKATAN="' . $hasil[0]['ANGKATAN'] . '" and KODE_PELATIHAN="' . $hasil[0]['KODE_PELATIHAN'] . '" ')->row()->jum_pk;
        $hadir = ($jumlah_hadir / $jumlah_peserta_kelas) * 100;
        $hadir = number_format(($hadir), 0, '.', '');
        $display['hadir'] = $hadir;
        $display['jumlah_peserta_kelas'] = $jumlah_peserta_kelas;

        $display['jum_sesi'] = $total / $persesi;
        $display['cur_sesi'] = $sesi;

        $getOveral = $this->calculate_overal($total / $persesi, $hasil, 0);
        $jumlah_komentar = $this->db->query('SELECT COUNT(KOMENTAR) AS jum_komentar FROM `komentar_sesi` natural join user WHERE KODE_PELATIHAN="' . $hasil[0]['KODE_PELATIHAN'] . '" and ANGKATAN=' . $hasil[0]['ANGKATAN'] . ' and nomor_sesi=' . $sesi . '')->row()->jum_komentar;
        $komentar = $this->db->query('SELECT NAMA,KOMENTAR FROM `komentar_sesi` natural join user WHERE KODE_PELATIHAN="' . $hasil[0]['KODE_PELATIHAN'] . '" and angkatan=' . $hasil[0]['ANGKATAN'] . ' and nomor_sesi=' . $sesi . '');
        $komentar = $komentar->result_array();
        $display['komentar'] = $komentar;
        $display['jumlah_komentar'] = $jumlah_komentar;

        $jumlah_tanggapan = $this->db->query('SELECT COUNT(KOMENTAR) AS jum_pengajar FROM `komentar_pengajar` natural join user WHERE KODE_PELATIHAN="' . $hasil[0]['KODE_PELATIHAN'] . '" and ANGKATAN=' . $hasil[0]['ANGKATAN'] . ' and nomor_sesi=' . $sesi . '')->row()->jum_pengajar;
        $tanggapan = $this->db->query('SELECT NAMA,KOMENTAR FROM `komentar_pengajar` natural join user WHERE KODE_PELATIHAN="' . $hasil[0]['KODE_PELATIHAN'] . '" and angkatan=' . $hasil[0]['ANGKATAN'] . ' and nomor_sesi=' . $sesi . '');
        $tanggapan = $tanggapan->result_array();
        $display['tanggapan'] = $tanggapan;
        $display['jumlah_tanggapan'] = $jumlah_tanggapan;
        $nilai_overal[0] = 0;
        $count_overal = 0;
        for ($q = 1; $q <= ($total / $persesi); $q++) {
            if ($getOveral['jumlah_overal'][$q] != 0) {
                $jumlah_hadir = $this->db->query('SELECT COUNT(ID) as jumlah FROM `absen` WHERE ANGKATAN="' . $hasil[0]['ANGKATAN'] . '" and KODE_PELATIHAN="' . $hasil[0]['KODE_PELATIHAN'] . '" and NOMOR_SESI=' . $q . '')->row()->jumlah;
//                echo "<br>".$jumlah_hadir;
                $temp_overal = $getOveral['overal_sesi'][$q];
                $nilai_overal[0] = $nilai_overal[0] + (((95 / 100) * $temp_overal) + ((5 / 100) * (($jumlah_hadir / 17) * $temp_overal)));
                $count_overal+=1;
            }
        }
        $nilai_overal[0] = $nilai_overal[0] / $count_overal;
        $nilai_overal[0] = $this->decimal($nilai_overal[0]);
        if ($nilai_overal[0] >= 85) {
            $nilai_overal[1] = "A+";
            $nilai_overal[2] = "Excellent";
        } else if ($nilai_overal[0] >= 80) {
            $nilai_overal[1] = "A";
            $nilai_overal[2] = "Very Good";
        } else if ($nilai_overal[0] >= 75) {
            $nilai_overal[1] = "B+";
            $nilai_overal[2] = "Good";
        } else if ($nilai_overal[0] >= 70) {
            $nilai_overal[1] = "B";
            $nilai_overal[2] = "Fair";
        } else if ($nilai_overal[0] >= 60) {
            $nilai_overal[1] = "C";
            $nilai_overal[2] = "Poor";
        } else {
            $nilai_overal[1] = "D";
            $nilai_overal[2] = "Very Poor";
        }
        $display['overal_score'] = $nilai_overal;

        $display['nilai_rata_materi_allsesi'] = $getOveral['nilai_rata_materi_allsesi'];
        $display['nilai_rata_instruktur_allsesi'] = $getOveral['nilai_rata_instruktur_allsesi'];
        $display['nilai_rata_asisten_allsesi'] = $getOveral['nilai_rata_asisten_allsesi'];
        $display['jumlah_asisten'] = $getOveral['jumlah_asisten'][$sesi];
        $display['nilai_asisten'] = $getOveral['nilai_asisten'][$sesi];
        $display['nilai_rata_asisten'] = $getOveral['nilai_rata_asisten'][$sesi];
        $display['jumlah_materi'] = $getOveral['jumlah_materi'][$sesi];
        $display['materi'] = $getOveral['materi'][$sesi];
        $display['nilai_instruktur'] = $getOveral['nilai_instruktur'][$sesi];
        $display['nama_instruktur'] = $getOveral['nama_instruktur'][$sesi];
        $display['like'] = $getOveral['like'][$sesi];
        $display['jumlah_like'] = $getOveral['jumlah_like'][$sesi];

        if ($getOveral['overal_sesi'][$sesi] >= 85) {
            $grade = "A+";
            $quote = "Excellent";
        } else if ($getOveral['overal_sesi'][$sesi] >= 80) {
            $grade = "A";
            $quote = "Very Good";
        } else if ($getOveral['overal_sesi'][$sesi] >= 75) {
            $grade = "B+";
            $quote = "Good";
        } else if ($getOveral['overal_sesi'][$sesi] >= 70) {
            $grade = "B";
            $quote = "Fair";
        } else if ($getOveral['overal_sesi'][$sesi] >= 60) {
            $grade = "C";
            $quote = "Poor";
        } else {
            $grade = "D";
            $quote = "Very Poor";
        }
        
        $query = $this->db->query('select * from daftar_jadwal where KODE_PELATIHAN="'.$kode.'" and ANGKATAN='.$angk.' and NOMOR_SESI='.$sesi)->result_array();
        if(count($query)>0){
            // daftar nama bulan
            $months = Array (1=>"Jan", 2=>"Peb", 3=>"Mar", 4=>"Apr",
            5=>"Mei", 6=>"Jun", 7=>"Jul", 8=>"Agust", 9=>"Sept",
            10=>"Okt", 11=>"Nov", 12=>"Des");

            $newDate = date("n", strtotime($query[0]['TANGGAL'])); // ambil array nama bulan sesuai nomor bulan
            $tanggal['date'] = date("j", strtotime($query[0]['TANGGAL']));
            $tanggal['month'] = $months[$newDate];
            $tanggal['year'] = date("Y", strtotime($query[0]['TANGGAL']));
            
        }else {
            $tanggal['date'] = '01';
            $tanggal['month'] = 'Jan';
            $tanggal['year'] = '1900';
        }
        
        $display['tanggal'] = $tanggal;
        
        $display['grade'] = $grade;
        $display['quote'] = $quote;
        $display['overal_sesi'] = $getOveral['overal_sesi'];
        $display['jumlah_overal'] = $getOveral['jumlah_overal'];

        $query_term = $this->db->query('select * from term')->result_array();
        $list_term = array();
        $cur_term = 0;
        if (count($query_term) != 0) {
            for ($p = 0; $p < count($query_term); $p++) {
                $list_term[$query_term[$p]['NO_TERM'] . '/' . $query_term[$p]['TAHUN']] = "Term " . $query_term[$p]['NO_TERM'] . " - " . $query_term[$p]['TAHUN'];
            }
        } else {
            $list_term = $query_term;
        }
        $header_term['list_term'] = $list_term;
        $header_term['cur_term'] = $term_sf . "/" . $tahun_sf;

//        $attr = 'onChange="document.location.href=\''.base_url().'feedback_result/feedback_result_con/start_home/'.$term_sf.'/'.$tahun_sf.'\';"';
        $attr = 'id="list_term" onChange="call(\'' . base_url() . 'feedback_result/feedback_result_con/\')"';
        $header_term['atribut'] = $attr;
        $display['cur_term'] = $term_sf . "/" . $tahun_sf;

        $this->load->view('feedback_result/feedback_result_header_view', $header_term);
        $this->load->view('feedback_result/hasil_course', $display);
        $this->load->view('feedback_result/feedback_result_footer_view');
    }

    function change_term($term_sf, $tahun_sf) {
//        echo "<br>".$this->session->userdata('no_term');
//        echo "<br>".$this->session->userdata('tahun_term');
        $this->session->set_userdata('no_term', $term_sf);
        $this->session->set_userdata('tahun_term', $tahun_sf);
//        echo "<br>".$this->session->userdata('no_term');
//        echo "<br>".$this->session->userdata('tahun_term');
        redirect(base_url() . 'feedback_result/feedback_result_con/start_home');
    }

    function calculate_overal($jumsesi, $hasil, $data) {
        $sum_instruktur_allsesi = 0;
        $sum_asisten_allsesi = 0;
        $sum_materi_allsesi = 0;
        $count_instruktur_allsesi = 0;
        $count_asisten_allsesi = 0;
        $count_materi_allsesi = 0;
        for ($r = 1; $r <= ($jumsesi); $r++) {
            $jumlah_materi[$r] = $this->db->query('select COUNT(NILAI_PEMAHAMAN) as jumlah_materi from komentar_sesi where NOMOR_SESI=' . $r . ' and KODE_PELATIHAN="' . $hasil[$data]['KODE_PELATIHAN'] . '" and ANGKATAN=' . $hasil[$data]['ANGKATAN'])->row()->jumlah_materi;
            $materi[$r] = $this->db->query('select AVG(NILAI_PEMAHAMAN) as rata from komentar_sesi where NOMOR_SESI=' . $r . ' and KODE_PELATIHAN="' . $hasil[$data]['KODE_PELATIHAN'] . '" and ANGKATAN=' . $hasil[$data]['ANGKATAN'])->row()->rata;
            $materi[$r] = $this->decimal($materi[$r] * 10);
            if ($materi[$r] != 0) {
                $sum_materi_allsesi+=$materi[$r];
                $count_materi_allsesi+=1;
            }
            $instruktur[$r] = $this->db->query('select distinct ID from ajar natural join nilai_pengajar where ajar.kode_pelatihan="' . $hasil[$data]['KODE_PELATIHAN'] . '" and ajar.ANGKATAN=' . $hasil[$data]['ANGKATAN'] . ' and ajar.NOMOR_SESI=' . $r . ' and ajar.PERAN="instruktur" and nilai_pengajar.abstain=0')->result_array();
//            $instruktur[$r] = $this->db->query('select distinct ID from ajar where kode_pelatihan="'.$hasil[$data]['KODE_PELATIHAN'].'" and ANGKATAN='.$hasil[$data]['ANGKATAN'].' and NOMOR_SESI='.$r.' and PERAN="instruktur"')->result_array();

//            for ($j = 0; $j < count($instruktur[$r]); $j++) {
//                echo "instruktur sesi".$r.":".$j.":".$instruktur[$r][$j]['ID'];
//            }
            if (count($instruktur[$r]) > 0) {
                $sum = 0;
                $nilai_cari_instruktur[$r] = $this->db->query('select NILAI from nilai_pengajar where KODE_PELATIHAN="' . $hasil[$data]['KODE_PELATIHAN'] . '" and ANGKATAN=' . $hasil[$data]['ANGKATAN'] . ' and NOMOR_SESI=' . $r . '  and ID_DINILAI=' . $instruktur[$r][0]['ID'] . '')->result_array();
//                echo "<br>".$r.", ".$hasil[$data]['KODE_PELATIHAN'].",".$hasil[$data]['ANGKATAN'].":".count($nilai_cari_instruktur[$r]);
                if (count($nilai_cari_instruktur[$r]) != 0) {
                    for ($j = 0; $j < count($nilai_cari_instruktur[$r]); $j++) {
//                    echo " =".$nilai_cari_instruktur[$r][$j]['NILAI'];
                        $sum+=$nilai_cari_instruktur[$r][$j]['NILAI'];
                    }
                    $nilai_instruktur[$r] = $this->decimal($sum / count($nilai_cari_instruktur[$r]));
//                    echo ' dibagi '.count($nilai_cari_instruktur[$r]);
//                echo "<br>hasil instruktur=".$sum." dibagi ".count($nilai_cari_instruktur[$r])." = ".$nilai_instruktur[$r];
                } else {
                    $nilai_instruktur[$r] = 0;
                }
            } else {
                $nilai_instruktur[$r] = 0;
            }
            $instruktur[$r] = $this->db->query('select NAMA  from user natural join ajar where ajar.KODE_PELATIHAN="' . $hasil[$data]['KODE_PELATIHAN'] . '" and ajar.angkatan=' . $hasil[$data]['ANGKATAN'] . ' and ajar.nomor_sesi=' . $r . ' and ajar.peran="instruktur"');
            $nama_instruktur[$r] = $instruktur[$r]->result_array();

            $asisten[$r] = $this->db->query('select distinct user.ID,user.NAMA from (ajar inner join nilai_pengajar on ajar.ID=nilai_pengajar.ID_DINILAI) inner join user on user.ID=ajar.ID where ajar.kode_pelatihan="' . $hasil[$data]['KODE_PELATIHAN'] . '" and ajar.ANGKATAN=' . $hasil[$data]['ANGKATAN'] . ' and ajar.NOMOR_SESI=' . $r . ' and ajar.PERAN="asisten" and nilai_pengajar.abstain=0')->result_array();
//               echo "<br>jumlah asisten di sesi".$r."=".count($asisten[$r]);
//            for ($j=0;$j<count($asisten[$r]);$j++) {
//                echo $r."asis".$j.$asisten[$r][$j]['ID'];
//            }
            if (count($asisten[$r]) > 0) {
                $jumlah_nilai_asisten = 0;
                for ($j = 0; $j < count($asisten[$r]); $j++) {
                    $sum = 0;
                    $count_asisten = 0;
                    $nilai_cari_asisten[$r] = $this->db->query('select NILAI from nilai_pengajar where KODE_PELATIHAN="' . $hasil[$data]['KODE_PELATIHAN'] . '" and ANGKATAN=' . $hasil[$data]['ANGKATAN'] . ' and NOMOR_SESI=' . $r . '  and ID_DINILAI=' . $asisten[$r][$j]['ID'] . '')->result_array();
//                    echo "<br>.".count($nilai_cari_asisten[$r]);
                    if (count($nilai_cari_asisten[$r]) != 0) {
                        for ($k = 0; $k < count($nilai_cari_asisten[$r]); $k++) {
//                            echo " =".$nilai_cari_asisten[$r][$k]['NILAI'];
                            if ($nilai_cari_asisten[$r][$k]['NILAI'] != 0) {
                                $count_asisten+=1;
                                $sum+=$nilai_cari_asisten[$r][$k]['NILAI'];
                            }
//                            echo "sum =".$sum;
                        }
                        if ($count_asisten != 0) {
                            $nilai_asisten[$r] = $this->decimal($sum / $count_asisten);
                        } else {
                            $nilai_asisten[$r] = 0;
                        }
                    } else {
                        $nilai_asisten[$r] = 0;
                    }
//                    echo "<br>hasil sesi".$r."=".$sum." dibagi ".count($nilai_cari_asisten[$r])." = ".$nilai_asisten[$r];
                    $hasil_asisten[$r][$j]['rata_asisten'] = $nilai_asisten[$r];
                    $hasil_asisten[$r][$j]['NAMA'] = $asisten[$r][$j]['NAMA'];
//                    $nilai_asisten[$r] = $this->db->query('select AVG(NILAI) as avgjum1 from nilai_pengajar where KODE_PELATIHAN="'.$hasil[$data]['KODE_PELATIHAN'].'" and ANGKATAN='.$hasil[$data]['ANGKATAN'].' and NOMOR_SESI='.$r.'  and ID_DINILAI='.$asisten[$r][0]['ID'].'')->row()->avgjum1;
//                    echo "<br>.hasilavg=".$nilai_asisten[$r]['avgjum1'];
                    $jumlah_nilai_asisten+=$nilai_asisten[$r];
                }
                $nilai_rata_asisten[$r] = $jumlah_nilai_asisten / count($asisten[$r]);
            } else {
                $hasil_asisten[$r] = 0;
//                echo "<br>isi asisten nol".$hasil_asisten[$r][$j]['rata_asisten'];
                $nilai_rata_asisten[$r] = 0;
            }
            $jumlah_asisten[$r] = count($asisten[$r]);

            if ($nilai_instruktur[$r] != 0) {
                $sum_instruktur_allsesi+=$nilai_instruktur[$r];
                $count_instruktur_allsesi+=1;
//                echo '.'.$count_instruktur_allsesi.'';
            }
            if ($nilai_rata_asisten[$r] != 0) {
                $sum_asisten_allsesi+=$nilai_rata_asisten[$r];
                $count_asisten_allsesi+=1;
            }

            $jumlah_like[$r] = $this->db->query('SELECT COUNT(`LIKE`) as jum_like FROM `komentar_sesi` WHERE kode_pelatihan="' . $hasil[$data]['KODE_PELATIHAN'] . '" and angkatan=' . $hasil[$data]['ANGKATAN'] . ' and nomor_sesi=' . $r . '')->row()->jum_like;
            $like[$r] = $this->db->query('SELECT avg(`LIKE`) as like_aja FROM `komentar_sesi` WHERE kode_pelatihan="' . $hasil[$data]['KODE_PELATIHAN'] . '" and angkatan=' . $hasil[$data]['ANGKATAN'] . ' and nomor_sesi=' . $r . '')->row()->like_aja;
            $convert[$r] = number_format($like[$r] * 100, 0, '.', '');
            if ($jumlah_asisten[$r] != 0) {
                $nilai_pengajar = ((80 / 100) * $nilai_instruktur[$r]) + ((20 / 100) * $nilai_rata_asisten[$r]);
            } else {

                $nilai_pengajar = $nilai_instruktur[$r];
            }
            $overal_sesi[$r] = ((40 / 100) * $materi[$r]) + ((5 / 100) * $like[$r]) + ((55 / 100) * $nilai_pengajar);
            $overal_sesi[$r] = $this->decimal($overal_sesi[$r]);
//            if($r==1){
//                echo $jumlah_asisten[$r].'<br>';
//                echo $nilai_rata_asisten[$r]."<br>";
//                echo $nilai_instruktur[$r]."<br>";
//                echo $nilai_pengajar.'<br>';
//                echo $like[$r].'<br>';
//                echo $materi[$r];
//                echo $overal_sesi[$r];
//            }
            $jumlah_overal[$r] = $jumlah_materi[$r];
        }
        $nilai_rata_asisten_allsesi = 0;
        $nilai_rata_instruktur_allsesi = 0;
        $nilai_rata_materi_allsesi = 0;
//        echo "<br> jumlah asisten=".$sum_asisten_allsesi." ".$count_asisten_allsesi;
//        echo "<br> jumlah instruktur=".$sum_instruktur_allsesi." ".$count_instruktur_allsesi;
        if ($count_asisten_allsesi != 0) {
            $nilai_rata_asisten_allsesi = $this->decimal($sum_asisten_allsesi / $count_asisten_allsesi);
        }
        if ($count_instruktur_allsesi != 0) {
            $nilai_rata_instruktur_allsesi = $this->decimal($sum_instruktur_allsesi / $count_instruktur_allsesi);
//            echo '<br>ini dibagi berapa:'.$count_instruktur_allsesi.'<br>';
        }
        if ($count_materi_allsesi != 0) {
            $nilai_rata_materi_allsesi = $this->decimal($sum_materi_allsesi / $count_materi_allsesi);
        }

//        echo "<br> rata materi=".$nilai_rata_materi_allsesi;
//        echo "<br> rata asisten=".$nilai_rata_asisten_allsesi;
//        echo "<br> rata instruktur=".$nilai_rata_instruktur_allsesi;
        $result['nilai_rata_asisten_allsesi'] = $nilai_rata_asisten_allsesi;
        $result['nilai_rata_instruktur_allsesi'] = $nilai_rata_instruktur_allsesi;
        $result['nilai_rata_materi_allsesi'] = $nilai_rata_materi_allsesi;
        $result['jumlah_asisten'] = $jumlah_asisten;
        $result['nilai_asisten'] = $hasil_asisten;
        $result['nilai_rata_asisten'] = $nilai_rata_asisten;
        $result['jumlah_materi'] = $jumlah_materi;
        $result['materi'] = $materi;
        $result['nilai_instruktur'] = $nilai_instruktur;
        $result['nama_instruktur'] = $nama_instruktur;
        $result['like'] = $convert;
        $result['jumlah_like'] = $jumlah_like;
        $result['overal_sesi'] = $overal_sesi;
        $result['jumlah_overal'] = $jumlah_overal;
        return $result;
    }

    function decimal($num) {
        $decimal_part = $num - floor($num);
        if ($decimal_part == 0) {
            $result = number_format($num, 0, '.', '');
        } else {
            $result = number_format($num, 1, '.', '');
        }

        return $result;
    }

    function logout() {
        $this->session->sess_destroy();
        redirect(base_url() . 'feedback_result/feedback_result_con/login');
    }

    function nilai_tampil($nilai, $jml_hadir) {
        return $this->decimal(((95 / 100) * $nilai) + ((5 / 100) * $jml_hadir) / 17 * $nilai);
    }

    function tambah_komentar($kode, $angk, $sesi) {
        $komentar = $this->input->post('komentar');
        $data_komentar_pengajar = array(
            'ID' => $this->session->userdata('id'),
            'KODE_PELATIHAN' => $kode,
            'ANGKATAN' => $angk,
            'NOMOR_SESI' => $sesi,
            'KOMENTAR' => $komentar,
        );
        $this->db->insert('komentar_pengajar', $data_komentar_pengajar);

        redirect(base_url() . 'feedback_result/feedback_result_con/calculate_course/' . $kode . '/' . $angk . '/' . $sesi);
    }

    function error_display($jenis = 0) {
        $display['message_utama'] = '';
        $display['message_penjelasan'] = '';
        switch ($jenis) {
            case 0:
                $display['message_utama'] = 'Anda harus login terlebih dahulu';
                break;
            case 1:
                $display['message_utama'] = 'Ada kesalahan pada username atau password anda';
                break;
            case 2:
                $display['message_utama'] = 'Sekarang tidak ada SF yang tersedia ' . $jam_sekarang = date('H.i', time());
                ;
                $display['message_penjelasan'] = 'Silakan isi SF pada sesi yang aktif';
                break;
            case 3:
                $display['message_utama'] = 'Anda sudah mengisi SF untuk sesi ini';
                $display['message_penjelasan'] = 'Silakan isi SF pada sesi yang lain';
                break;
            case 4:
                $display['message_utama'] = 'Course yang dipilih tidak ada datanya';
                $display['message_penjelasan'] = 'Silakan isi terlebih dahulu datanya';
                break;
        }

        $this->load->view('feedback_result/feedback_result_header_view');
        $this->load->view('feedback_result/error_display', $display);
        $this->load->view('feedback_result/feedback_result_footer_view');
    }

}
